﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;
using Database.Classes;


public partial class StoredProcedures
{
    [Microsoft.SqlServer.Server.SqlProcedure]
    public static void AddPlayerToAlliance(int pId, int aId)
    {
        using (SqlConnection conn = new SqlConnection(StaticMethods.ConnectionString()))
        {
            conn.Open();
            using (SqlCommand cmd = new SqlCommand("Insert into AllianceMembers Values(@a, @p)", conn))
            {
                cmd.Parameters.Add("@a", SqlDbType.Int).Value = aId;
                cmd.Parameters.Add("@p", SqlDbType.Int).Value = pId;
                cmd.ExecuteNonQuery();
            }
        }
    }
    [Microsoft.SqlServer.Server.SqlProcedure]
    public static void CreateAlliance(string name, string password, string page)
    {
        using (SqlConnection conn = new SqlConnection(StaticMethods.ConnectionString()))
        {
            conn.Open();
            using (SqlCommand cmd = new SqlCommand("Insert into Alliances Values(@n, @p, @pass)", conn))
            {
                cmd.Parameters.Add("@n", SqlDbType.NVarChar).Value = name;
                cmd.Parameters.Add("@p", SqlDbType.NVarChar).Value = page;
                cmd.Parameters.Add("@pass", SqlDbType.NVarChar).Value = password;
               int i= cmd.ExecuteNonQuery();
               //throw new Exception(i.ToString());
            }
        }
    }

    
};
